package myJs.cps

import japgolly.scalajs.react.ScalaFnComponent
import japgolly.scalajs.react.facade.React
import myJs.myPkg.reactDraggable._
import myJs.myPkg.reactBootstrap._
import japgolly.scalajs.react.vdom.all._

import scala.scalajs.js

/** Created by yz on 21/1/2022
  */
object DraggableModalDialogCp {

  case class Props(
      centered: js.UndefOr[Boolean] = js.undefined,
      contentClassName: js.UndefOr[String] = js.undefined,
      scrollable: js.UndefOr[Boolean] = js.undefined,
      size: js.UndefOr[String] = js.undefined,
      bsPrefix: js.UndefOr[String] = js.undefined,
      children: js.Array[React.Node],
      fullscreen: js.UndefOr[Boolean] = js.undefined
  )

  val Component = MyScalaFnComponent[Props] { props =>
    Draggable(handle = ".modal-title")(
      ModalDialog(
        centered = props.centered,
        contentClassName = props.contentClassName,
        scrollable = props.scrollable,
        bsPrefix = s"${props.size} modal",
        fullscreen = props.fullscreen
      )(
        props.children.toVdomArray
      )
    )
  }

}
